package com.base.engine.graphics;

import java.util.ArrayList;

import com.base.engine.error.VertexException;

public class VertexList3f {

	private ArrayList<VertexArray3f> data ;
	
	public VertexList3f(){
		data = new ArrayList<VertexArray3f>(); 
	}
	
	public VertexList3f(VertexArray3f vertices){
		this(); 
		addSingleVertexArray(vertices);
	}
	
	public VertexList3f(VertexArray3f[] vertices){
		this();
		addMultipleVertexArrays(vertices);
	}
	
	public void addMultipleVertexArrays(ArrayList<VertexArray3f> vertices){
		if(vertices == null) VertexException.NullPointerException(); 
		else{ 
			for(VertexArray3f v: vertices)
				addSingleVertexArray(v);
		}
	}
	
	public void addMultipleVertexArrays(VertexArray3f[] vertices){
		if(vertices == null) VertexException.NullPointerException();
		else{
			for(VertexArray3f v: vertices)
				addSingleVertexArray(v);
		}
	}
	
	public void addSingleVertexArray(VertexArray3f vertices){
		if(vertices == null) VertexException.NullPointerException(); 
		else data.add(vertices);
	}
	
	public int getSize(){
		return data.size() ; 
	}
	
	public VertexArray3f getVertexArrayByName(String name){
		if(!(name == null)){
			for(VertexArray3f v: data){
				if(v.NAME.equals(name))
					return v ; 
			}
		}
		return null ; 
	}
	
	public VertexArray3f getVertexArrayByID(int id){
		for (VertexArray3f v : data) {
			if (v.getID() == id)
				return v;
		}
		return null;
	}

	public ArrayList<VertexArray3f> getAll(){
		return data	 ; 
	}
	
	public VertexArray3f[] getAllAsArray(){
		VertexArray3f[] tmp = new VertexArray3f[data.size()];
		for(int i=0; i<tmp.length; i++)
			tmp[i] = data.get(i);
		return tmp ; 
	}
	
}
